#ifndef __INCtaskManagerh
#define __INCtaskManagerh
#include <cstdint>
#include <type.h>
#include <objbase.h>
#include <task.h>
#include <posix.h>

class TaskManager : public objbase
{
public:
    DECLARE_CTOR_DTOR(TaskManager);
    OBJBASE_EXTERN_MEMBER_IMPL();
    STATUS addTask(TaskPtr task);
    STATUS removeTask(Task::TASK_ID taskId);
    TaskPtr findTask(Task::TASK_ID taskId);
    size_t getTaskCount() const;

private:
    PROCESS_DESC(sysShutdown);

private:
    DISABLE_COPY_CLASS(TaskManager);
    std::unordered_map<Task::TASK_ID, TaskPtr> m_tasks;
};

EXTERN_C_BEGIN
    STATUS objTaskEntry(const char *objTaskName,
                        FUNCPTR func, void *arg,
                        const char *file, int len);

#define CREATE_OBJTASK(objTaskName, func, pObjPara) \
    objTaskEntry(objTaskName, func, pObjPara, __FILE__, __LINE__)

EXTERN_C_END

#endif